<h1><?php echo dl_lang_general("main.heroes_mine"); ?></h1>

<?php
setMessages();

$s = dibi::query("SELECT * 
                    FROM hero 
                   WHERE account = %i", $data["user"]["id"], 
               "ORDER BY created DESC");
$heroes = $s->fetchAll();

if (count($heroes) < 4)
{
    echo '<button style="float: right" onclick="window.location=\''.$base."heroes/new".'\';">'.dl_lang_general("main.heroes_create").'</button>';
}

if (count($heroes) == 0)
{
    echo "<br /><br /><br />".html_info(dl_lang_general("msg.no_hero"));
}

$races = getInum("RACE");
$pohlavi = getInum("SEX");

echo '<div style="clear: both;"></div>';

foreach ($heroes AS $h)
{    
    echo '<table style="padding-top: 10px;" cellpadding="3">
            <tr>
                <td><div class="avatar"><img src="images/avatar/'.($h->avatar == "" ? "no_avatar.jpg" : $h->avatar).'" class="avatar-big"><div class="avatar-big-frame"></div></div></td>
                <td valign="top">
                    <div class="hero-name">'.$h->name.'</div>
                    <div class="hero-detail">level '.$h->level.' '.$pohlavi[$h->pohlavi].' '.$races[$h->race].'</div>
                    <br />
                    <strong>'.dl_lang_general("main.gold").':</strong> '.$h->gold.'<br />
                    <strong>'.dl_lang_general("main.experiences").':</strong> '.$h->exp.'<br /><br />
                    <center><button onclick="window.location=\''.$base."heroes/".$h->id.'\';">'.dl_lang_general("main.hero_select").'</button> <button onclick="window.location=\''.$base."heroes/".$h->id.'\';">'.dl_lang_general("main.hero_detail").'</button></center>    
                </td> 
            </tr>
          </table>';
}
?>
<div style="clear: both;"></div>